//
//  TouchView.m
//  UI05_delegate设计模式实现view点击事件回调
//
//  Created by Scott on 16/5/9.
//  Copyright © 2016年 Scott. All rights reserved.
//

#import "TouchView.h"

@interface TouchView ()

// 声明target, action 属性.
@property (nonatomic, assign) id target;
@property (nonatomic, assign) SEL action;

@end


@implementation TouchView


- (void)addTarget:(id)target action:(SEL)action {
    
    self.target = target;
    self.action = action;
    
}

#pragma mark - override touch 
- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    [super touchesEnded:touches withEvent:event];
    
    // Core API: performSelector:
    // 让target 调用 selector(方法).
    [self.target performSelector:self.action withObject:self afterDelay:0];
    
    
}







@end
